﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcEngine.Core.Validation
{
    public class GuidEmptyValidatorAttribute : FieldValidatorAttribute
    {
        public GuidEmptyValidatorAttribute(string message)
            : base(message)
        {
            ErrorMessage = Message;
        }

        public override bool IsValid(object value)
        {
            if (value is Guid)
            {
                Guid val = (Guid)value;
                return val != Guid.Empty;
            }
            throw new ArgumentException("GuidEmptyValidatorAttribute can be applied only to non null Guids.");
        }
    }
}
